%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% MIT License
%
% Copyright (c) 2016 Microsoft
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
% in the Software without restriction, including without limitation the rights
% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
% copies of the Software, and to permit persons to whom the Software is
% furnished to do so, subject to the following conditions:
%
% The above copyright notice and this permission notice shall be included in
% all copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
% THE SOFTWARE.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 
% function aTCInterleave=getTurboCodeInterleaver();
%
% Return the Turbo code internal interleaver parameters as specified in Table 5.1.3-3, 36.212
%
function aTCInterleave=getTurboCodeInterleaver();


% Table 5.1.3-3
aTCInterleave = [1 40 3 10 48 416 25 52 95 1120 67 140 142 3200 111 240 ...
2 48 7 12 49 424 51 106 96 1152 35 72 143 3264 443 204 ...
3 56 19 42 50 432 47 72 97 1184 19 74 144 3328 51 104 ...
4 64 7 16 51 440 91 110 98 1216 39 76 145 3392 51 212 ...
5 72 7 18 52 448 29 168 99 1248 19 78 146 3456 451 192 ...
6 80 11 20 53 456 29 114 100 1280 199 240 147 3520 257 220 ...
7 88 5 22 54 464 247 58 101 1312 21 82 148 3584 57 336 ...
8 96 11 24 55 472 29 118 102 1344 211 252 149 3648 313 228 ...
9 104 7 26 56 480 89 180 103 1376 21 86 150 3712 271 232 ...
10 112 41 84 57 488 91 122 104 1408 43 88 151 3776 179 236 ...
11 120 103 90 58 496 157 62 105 1440 149 60 152 3840 331 120 ...
12 128 15 32 59 504 55 84 106 1472 45 92 153 3904 363 244 ...
13 136 9 34 60 512 31 64 107 1504 49 846 154 3968 375 248 ...
14 144 17 108 61 528 17 66 108 1536 71 48 155 4032 127 168 ...
15 152 9 38 62 544 35 68 109 1568 13 28 156 4096 31 64 ...
16 160 21 120 63 560 227 420 110 1600 17 80 157 4160 33 130 ...
17 168 101 84 64 576 65 96 111 1632 25 102 158 4224 43 264 ...
18 176 21 44 65 592 19 74 112 1664 183 104 159 4288 33 134 ...
19 184 57 46 66 608 37 76 113 1696 55 954 160 4352 477 408 ...
20 192 23 48 67 624 41 234 114 1728 127 96 161 4416 35 138 ...
21 200 13 50 68 640 39 80 115 1760 27 110 162 4480 233 280 ...
22 208 27 52 69 656 185 82 116 1792 29 112 163 4544 357 142 ...
23 216 11 36 70 672 43 252 117 1824 29 114 164 4608 337 480 ...
24 224 27 56 71 688 21 86 118 1856 57 116 165 4672 37 146 ...
25 232 85 58 72 704 155 44 119 1888 45 354 166 4736 71 444 ...
26 240 29 60 73 720 79 120 120 1920 31 120 167 4800 71 120 ...
27 248 33 62 74 736 139 92 121 1952 59 610 168 4864 37 152 ...
28 256 15 32 75 752 23 94 122 1984 185 124 169 4928 39 462 ...
29 264 17 198 76 768 217 48 123 2016 113 420 170 4992 127 234 ...
30 272 33 68 77 784 25 98 124 2048 31 64 171 5056 39 158 ...
31 280 103 210 78 800 17 80 125 2112 17 66 172 5120 39 80 ...
32 288 19 36 79 816 127 102 126 2176 171 136 173 5184 31 96 ...
33 296 19 74 80 832 25 52 127 2240 209 420 174 5248 113 902 ...
34 304 37 76 81 848 239 106 128 2304 253 216 175 5312 41 166 ...
35 312 19 78 82 864 17 48 129 2368 367 444 176 5376 251 336 ...
36 320 21 120 83 880 137 110 130 2432 265 456 177 5440 43 170 ...
37 328 21 82 84 896 215 112 131 2496 181 468 178 5504 21 86 ...
38 336 115 84 85 912 29 114 132 2560 39 80 179 5568 43 174 ...
39 344 193 86 86 928 15 58 133 2624 27 164 180 5632 45 176 ...
40 352 21 44 87 944 147 118 134 2688 127 504 181 5696 45 178 ...
41 360 133 90 88 960 29 60 135 2752 143 172 182 5760 161 120 ...
42 368 81 46 89 976 59 122 136 2816 43 88 183 5824 89 182 ...
43 376 45 94 90 992 65 124 137 2880 29 300 184 5888 323 184 ...
44 384 23 48 91 1008 55 84 138 2944 45 92 185 5952 47 186 ...
45 392 243 98 92 1024 31 64 139 3008 157 188 186 6016 23 94 ...
46 400 151 40 93 1056 17 66 140 3072 47 96 187 6080 47 190 ...
47 408 155 102 94 1088 171 204 141 3136 13 28 188 6144 263 480];
aTCInterleave = reshape(aTCInterleave', 16, 47)';
aTCInterleave = [aTCInterleave(:,1:4); aTCInterleave(:,5:8); aTCInterleave(:,9:12); aTCInterleave(:,13:16)]; 
